﻿$(function () {
    $("#submit").click(function () {
        Submit();
    });

    $("#body").keypress(function (event) {
        if (event.which == '13') {
            Submit();
        }
    });
});

function Submit() {

    $("#submit").hide();

    var input = {
        ID: $("#id").val(),
        Name: $("#Name").val(),
        Time: $("#Time").val(),
        Location: $("#Location").val(),
        DisplayOrder: $("#DisplayOrder").val()
    };

    Ajax({
        url: "/JummahPrayers/SavePrayer",
        data: JSON.stringify(input),
        success: function (data) {
            if (data.IsValid == false) {
                ShowValidationErrors(data);
            } else if (data.IsSaved == true) {
                location.href = "/JummahPrayers?msg=3";
            }
        },
        complete: function () {
            $("#submit").show();
        }
    });
}